
<script type="text/javascript">

$(function(){
		   
	$('#txtNascimento').mask('99/99/9999');
	
	//busca disciplinas do combo
	$("#txtSala").load("actions/ajaxlistarSalasComboAction.php");
	
	//busca disciplinas do disciplina
	$("#txtDisciplina").load("actions/ajaxlistarDisciplinasComboAction.php");
	
	//busca disciplinas do combo
	$("#txtEsporteFavorito").load("actions/ajaxlistarEsporteComboAction.php");
		   
	$('#formPessoa').ajaxForm({
		dataType: 'json',
		beforeSubmit: function() {
			if( $("#formPessoa").validate({
				rules: {
					txtNome: "required",
					txtSobrenome: "required",
					txtUsuario: {
						required: true,
						minlength: 4
					},
					txtSenha: {
						required: true,
						minlength: 4
					},
					txtSenhaConfirma: {
						required: true,
						minlength: 4,
						equalTo: "#txtSenha"
					},
					txtEmail: {
						required: true,
						email: true
					}
				},
				messages: {
					txtNome: "Campo Obrigatório",
					txtSobrenome: "Campo Obrigatório",
					txtUsuario: {
						required: "Campo Obrigatório",
						minlength: "A senha deve possuir mais que 4 caracteres"
					},
					txtSenha: {
						required: "Campo Obrigatório",
						minlength: "A senha deve possuir mais que 4 caracteres"
					},
					txtSenhaConfirma: {
						required: "Campo Obrigatório",
						minlength: "A senha deve possuir mais que 4 caracteres",
						equalTo: "A senha não coincide"
					},
					txtEmail: "Entre com um e-mail valido"
				}
			}).form()==false ){
			 	return false;
			}
		},
		success: function(responseText, statusText) {
			if(responseText.sucesso){
				$.jAlert(responseText.mensagem, '', function(result) {
					window.location = "/?pg=login";												  
                });
			}else{
				$.jAlert(responseText.mensagem, '');
			}
		}

	})
	
	$("#content").css("height","750px");
	
	//carrega imagem
	$("#cfMudaImagem").load("componentes/mudaImagemCad.php");
	

})

	function mudarFoto(){
		$('#abri_imagem').dialog({show: "blind", hide: "explode", width:500, height:200, resizable:false}); 	
	}
	
	function buscaImagensPessoal(pessoa_id){
		$.ajax({
			type:"POST",
			url:"actions/listaImagensPessoalAction.php",
			data:{pessoa_id:pessoa_id},
			dataType:"json",
			success: function(data, textStatus, request){
				$("#fotoPessoa").html(data['imagem']);	
			}	
		});
	}


</script>

<div id="formularios">

<fieldset style="height:520px;width:800px;padding:10px;">
        <legend>
            <img src="../images/topoPaginas/Icon_Voce_Menu.png"/>
        </legend>
        <div id="btnSairForms">
        <a href="/?pg=login" title="Sair" style="border:0;">
        	<img src="images/btnOutros/btnSairForms.png"/>
        </a>
        </div>
        <div style="padding-left:90px;padding-top:40px;">
        
        <form action="actions/pessoaOrEscolaAction.php" method="post" id="formPessoa" name="formPessoa">
        	<table width="650" border="0">
              <tr>
                <td width="190" rowspan="5" align="center"> 
                
                	<div style="background:url(images/btnOutros/fundoFoto.png);width:83px;height:82px;">
                    	<span id="fotoPessoa"></span>
                    </div>
                    <span><a href="javascript:void(0);" onclick="mudarFoto()" style="color:#000;font-size:10px;">Incluir Foto</a></span>  
                	<input type="hidden" id="img_temp" name="img_temp"  />
                 </td>
                <td width="166"><span id="title">Seu Login </span><span style="color:#F00;">*<br />
                    <input type="text"  id="txtUsuario" name="txtUsuario"/>
                </span></td>
                <td width="30">&nbsp;</td>
                <td colspan="2">
                  <?php if($_SESSION['tipo_pessoa']=="P"){ ?>
                    <span id="title">Disciplina 1</span><br />
                    <select id="txtDisciplina" name="txtDisciplina">
                        <option>Selecione</option>
                    </select>
                <?php }else{ ?>
                    <span id="title">Sala</span><br />
                    <select id="txtSala" name="txtSala">
                        <option>Selecione</option>
                    </select>
                <?php } ?>
                </td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td width="122">&nbsp;</td>
                <td width="120">&nbsp;</td>
              </tr>
              <tr>
                <td><span id="title">Sua senha </span><span style="color:#F00;">*<br />
                    <input type="password"  id="txtSenha" name="txtSenha"/>
                </span></td>
                <td>&nbsp;</td>
                <td colspan="2"><span id="title">Repita sua senha </span><span style="color:#F00;">*<br />
                    <input type="password"  id="txtSenhaConfirma" name="txtSenhaConfirma"/>
                </span></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4"></td>
              </tr>
              <tr>
                <td><span id="title">Primeiro Nome</span><span style="color:#F00;">*</span><br />
                  <input type="text"  id="txtNome" name="txtNome"/>
                  <input type="hidden"  id="val" name="val" value="gravar"/>
                  <input type="hidden"  id="txtTipoPessoa" name="txtTipoPessoa" value="<? echo $_SESSION['tipo_pessoa']; ?>"/>
				  <input type="hidden"  id="txtEscolaID" name="txtEscolaID" value="<? echo $_SESSION['escola_id']; ?>"/>
				  
				  
				  
				  </td>
                <td><span id="title">Esporte Favorito</span><br />
                  <select id="txtEsporteFavorito" name="txtEsporteFavorito">
                  </select></td>
                <td><a href="#" title="E-mail" style="border:0;"><img src="images/btnOutros/btnEmail.png" height="22" width="22"/></a></td>
                <td colspan="2"><span id="title">E-mail</span><span style="color:#F00;"> *</span><br />
                  <input name="txtEmail" type="text"  id="txtEmail" size="40" maxlength="40"/>
                  <br /></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2"><span id="title">Sobrenome</span><span style="color:#F00;">*</span><br />
                  <input type="text"  id="txtSobrenome" name="txtSobrenome" size="50"/></td>
                <td><a href="/pg=home" title="Home" style="border:0;"><img src="images/btnOutros/btnHome.png" height="22" width="22"/></a></td>
                <td colspan="2"><span id="title">WebPage</span><br />
                  <input name="txtWebPage" type="text"  id="txtWebPage" size="40" maxlength="40"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><span id="title">Nascimento</span><br />
                  <input type="text"  id="txtNascimento" name="txtNascimento"/>
				</td>
                <td><span id="title">Sexo</span><br />
                  <input type="radio" id="txtSexo2" name="txtSexo" value="M"/>
                  <img src="images/btnOutros/masculino.png"/>
                  <input type="radio" id="txtSexo" name="txtSexo" value="F"/>
                  <img src="images/btnOutros/feminino.png"/> 
				</td>
                <td><a href="#" title="Twitter" style="border:0;"><img src="images/btnOutros/btnTwitter.png" height="22" width="22"/></a></td>
                <td colspan="2"><span id="title">Twitter</span><br />
                  <input name="txtTwitter" type="text"  id="txtTwitter" size="40" maxlength="40"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td><a href="#" title="Facebook" style="border:0;"><img src="images/btnOutros/btnFacebook.png" height="22" width="22"/></a></td>
                <td colspan="2"><span id="title">Facebook</span><br />
                  <input name="txtFacebook" type="text"  id="txtFacebook" size="40" maxlength="40"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>

          </form> 
      </div>
    </fieldset>
    
    <div style="position:relative;width:800px;height:40px;text-align:right;padding-right:10px;font-size:10px;color:#F00;">
    	* Campos de preenchimento Obrigatório
    </div>
    
    <div style="position:relative;width:800px;height:40px;text-align:center;">
    	<a href="javascript:void(0);" title="Salvar Alterações" onclick="$('#formPessoa').submit()" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnSalvar.png" />
        </a>
    </div>

</div>


<!-- -----------insere imagem Componente------------- -->
<div id="cfMudaImagem" style="display:none;"></div>
<!-- -----------insere imagem Componente------------- -->